<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<form action="4email.php" id="form1">
    邮箱：<input type="text" name="email" id="email"><br>
    手机号码：<input type="text" name="mobile" id="mobile"><br>
    <input type="submit">
</form>
<script>
    var form1 = document.getElementById('form1');
    var email = document.getElementById('email');
    var mobile = document.getElementById('mobile');
    form1.onsubmit = function (e) {
       // e.preventDefault();
        var emailP = /^\w+@[a-z0-9]{1,26}(\.[a-z]{2,5}){1,5}$/i;
//        console.log();
        if (!emailP.test(email.value)) {
            alert('邮箱格式错误');
            return false;
        }
    }
</script>
</body>
</html>